<script src="/javascripts/calendar/calendar.js" type="text/javascript"></script>
<script src="/javascripts/calendar/lang/calendar-ja.js" type="text/javascript"></script>
<script src="/javascripts/calendar/calendar-setup.js" type="text/javascript"></script>
<link href="/stylesheets/calendar.css" media="screen" rel="stylesheet" type="text/css" />

<h2><%= link_to h(l(:daizu_name) + l(:top_page)), :controller => 'daizu_main', :action => 'index' %> <%= l(:title_arrow) %> <%= l(:ticket_report) %></h2>

<% form_tag({ :controller => 'daizu_ticket_report', :action => 'index' }, :id => 'query_form') do %>
  <p><label for="issue_assigned_to_id"><%= l(:issue_assigned) %></label>
  <select name="assigned_to_id">
    <% @all_users.each do |user| %>
      <option value="<%= user.id %>"><%= user.name %></option>
    <% end %>
  </select>
  </p>

  <p><label for="issue_start_date"><%= l(:start_date) %></label>
  <input id="issue_start_date" name="start_date" size="15" type="text" value="<%= params[:start_date] %>" />
  <img alt="Calendar" class="calendar-trigger" id="issue_start_date_trigger" src="/images/calendar.png" />
  <script type="text/javascript">
  //<![CDATA[
  Calendar.setup({inputField : 'issue_start_date', ifFormat : '%Y-%m-%d', button : 'issue_start_date_trigger' });
  //]]>
  </script></p>

  <p><label for="issue_due_date"><%= l(:due_date) %></label>
  <input id="issue_due_date" name="due_date" size="15" type="text" value="<%= params[:due_date] %>" />
  <img alt="Calendar" class="calendar-trigger" id="issue_due_date_trigger" src="/images/calendar.png" />
  <script type="text/javascript">
  //<![CDATA[
  Calendar.setup({inputField : 'issue_due_date', ifFormat : '%Y-%m-%d', button : 'issue_due_date_trigger' });
  //]]>
  </script></p>
  
  <button type="submit">GO</button>
<% end %>

<% if @all_issues %>
  <p>[from:<%= params[:start_date] %> to:<%= params[:due_date] %>] <%= @target_user %><%= l(:ticket_report) %></p>

  <table class="list issues">
    <tr>
      <th><%= l(:id) %></th>
      <th><%= l(:project) %></th>
      <th><%= l(:tracker) %></th>
      <th><%= l(:title) %></th>
      <th><%= l(:issue_assigned) %></th>
      <th><%= l(:status) %></th>
      <th><%= l(:start_date) %></th>
      <th><%= l(:due_date) %></th>
      <th><%= l(:progress) %></th>
    </tr>

    <% @all_issues.each do |issue| %>
      <tr>
        <td><%= issue.id %></td>
        <td><%= Project.find(:first, :conditions => ["id = ?", issue.project_id]) %></td>
        <td><%= Tracker.find(:first, :conditions => ["id = ?", issue.tracker_id]) %></td>
        <td><%= issue.subject %></td>
        <td><%= User.find(:first, :conditions => ["id = ?", issue.assigned_to_id]) %></td>
        <td><%= IssueStatus.find(:first, :conditions => ["id = ?", issue.status_id])  %></td>
        <td><%= issue.start_date %></td>
        <td><%= issue.due_date %></td>
        <td>
          <table class="progress" style="width: 80px;">
            <tr>
              <% if issue.done_ratio <= 0  %>
                <td class="todo" style="width:100%;"></td>
              <% elsif issue.done_ratio >= 100 %>
                <td class="closed" style="width:100%;"></td>
              <% else %>
                <td class="closed" style="<%= "width:" + issue.done_ratio.to_s + "%;" %>"></td>
                <td class="todo" style="<%= "width:" + (100 - issue.done_ratio.to_i).to_s + "%;" %>"></td>
              <% end %>
            </tr>
          </table>
          <p class="pourcent"><%= issue.done_ratio.to_s + "%" %></p>
        </td>
      </tr>
    <% end %>
  </table>
<% end %>

